package com.xiaomi.baidumap.favorite.model;

import com.xiaomi.baidumap.model.Repo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 16-9-2.
 */
public class RepoConverter {

    /*
    * "id": 892275,
    "name": "retrofit",
    "full_name": "square/retrofit",
    "description": "Type-safe HTTP client for Android and Java by Square, Inc.",
    "stargazers_count": 13283,
    "forks_count": 2656,
    "avatar_url": "https://avatars.githubusercontent.com/u/82592?v=3",
    "group":{
    "id": 1,
    "name": "网络连接"
  }
    * */
    public static LocalRepo conveter(Repo repos){
        LocalRepo localRepo = new LocalRepo();
        localRepo.setId(repos.getId());
        localRepo.setName(repos.getName());
        localRepo.setFullName(repos.getFullName());
        localRepo.setDescription(repos.getDescription());
        localRepo.setStartsCount(repos.getStargazersCount());
        localRepo.setForksCount(repos.getForksCount());
        localRepo.setAvatar(repos.getOwner().getAvatar());
        localRepo.setGroup(null);
        return localRepo;
    }

    public static List<LocalRepo> coveterList(List<Repo> repos){
        List<LocalRepo> localRepos = new ArrayList<>();
        for (Repo repo:repos) {
            conveter(repo);
        }
        return localRepos;
    }
}
